﻿// Copyright 2009 Mike Geise
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Falcon.Core.Services
{
	using System.Collections.Generic;
	using Falcon.Core.Collections;
	using Falcon.Core.Domain;
	using Falcon.Core.Domain.Repositories;
	using Falcon.Core.Domain.Services;

	public class UserCommentService : IUserCommentService
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="UserCommentService"/> class.
		/// </summary>
		/// <param name="userCommentRepository">The user comment repository.</param>
		public UserCommentService(IUserCommentRepository userCommentRepository)
		{
			this.UserCommentRepository = userCommentRepository;
		}

		/// <summary>
		/// Gets or sets the user comment repository.
		/// </summary>
		/// <value>The user comment repository.</value>
		public IUserCommentRepository UserCommentRepository
		{
			get; 
			private set;
		}

		/// <summary>
		/// Gets the user comment by the specified specification.
		/// </summary>
		/// <param name="specification">The <see cref="UserCommentSpecification"/>.</param>
		/// <returns></returns>
		public UserComment GetBy(UserCommentSpecification specification)
		{
			return this.UserCommentRepository.GetBy(specification);
		}

		/// <summary>
		/// Gets the user comment by id.
		/// </summary>
		/// <param name="id">The id.</param>
		/// <returns></returns>
		public UserComment GetById(int id)
		{
			return this.UserCommentRepository.GetById(id);
		}

		/// <summary>
		/// Gets all the user comments.
		/// </summary>
		/// <returns></returns>
		public IList<UserComment> GetAll()
		{
			return this.GetPaged(new UserCommentSpecification()).Items;
		}

		/// <summary>
		/// Gets all the user comments.
		/// </summary>
		/// <param name="specification">The <see cref="UserCommentSpecification"/>.</param>
		/// <returns></returns>
		public IPagedList<UserComment, UserCommentSpecification> GetPaged(UserCommentSpecification specification)
		{
			return this.UserCommentRepository.GetPaged(specification);
		}

		/// <summary>
		/// Creates the user comment.
		/// </summary>
		/// <returns></returns>
		public UserComment Create()
		{
			return new UserComment();
		}

		/// <summary>
		/// Inserts the user comment into the storage.
		/// </summary>
		/// <param name="comment">The <see cref="UserComment"/>.</param>
		public void Insert(UserComment comment)
		{
			this.UserCommentRepository.Insert(comment);
		}

		/// <summary>
		/// Updates the user comment in the storage.
		/// </summary>
		/// <param name="comment">The <see cref="UserComment"/>.</param>
		public void Update(UserComment comment)
		{
			this.UserCommentRepository.Update(comment);
		}

		/// <summary>
		/// Deletes the user comment in the storage.
		/// </summary>
		/// <param name="comment">The <see cref="UserComment"/>.</param>
		public void Delete(UserComment comment)
		{
			this.UserCommentRepository.Delete(comment);
		}
	}
}